﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;

public partial class UserControls_BookInformation : System.Web.UI.UserControl
{
    SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string bookID = Request.QueryString["BookId"].ToString();

            string sqltest = "select * from Book where Id='" + bookID + "'";
            sqlconn.Open();
            SqlCommand sqlcom = new SqlCommand(sqltest, sqlconn);
            SqlDataReader read = sqlcom.ExecuteReader();
            read.Read();
            if (read.HasRows)
            {
                LabelType.Text = read.GetValue(1).ToString();
                LabelName.Text = read.GetValue(2).ToString();
                LabelAuthor.Text = read.GetValue(3).ToString();
                LabelPublisher.Text = read.GetValue(4).ToString();
                ImageCover.ImageUrl = read.GetValue(5).ToString();
                LabelDescription.Text = read.GetValue(6).ToString();
                LabelHits.Text = read.GetValue(7).ToString() ;
            }
        }
    }
}
